package com.framework.loippi.service.impl;

import com.framework.loippi.entity.User;
import com.framework.loippi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.framework.loippi.dao.FeedbackDao;
import com.framework.loippi.entity.Feedback;
import com.framework.loippi.service.FeedbackService;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Date;

/**
 * SERVICE -Feedback
 * 
 * @author Loippi Team
 * @version 1.0
 */
@Service
public class FeedbackServiceImpl extends GenericServiceImpl<Feedback, Long> implements FeedbackService {
	
	@Autowired
	private FeedbackDao feedbackDao;
	@Resource
	private UserService userService;
	
	@Autowired
	public void setGenericDao() {
		super.setGenericDao(feedbackDao);
	}


	@Override
	@Transactional
	public Long markDeal(Long[] ids) {
		Feedback feedback = null;
		User current = null;
		for (Long id : ids) {
			feedback = new Feedback();
			feedback.setId(id);
			feedback.setStatus(1);
			current = userService.getCurrent();
			feedback.setHandlerId(current.getId());
			feedback.setHandlerName(current.getNickname());
			feedback.setHandlerAccount(current.getUsername());
			feedback.setReplyTime(new Date());
			feedbackDao.update(feedback);
		}
		return 1L;
	}
}
